package com.hup.minicontroller.common.bluetooth;

import com.hup.minicontroller.common.bluetooth.handler.BtDataSplitCodecHandler;
import com.hup.minicontroller.common.netty.NettyConstant;
import com.hup.minicontroller.common.netty.NettyConstant.DataType;

import java.util.UUID;

/**
 * 蓝牙帧数据,数据类型类;与 {@link NettyConstant}保持一致
 *
 * @author hugan
 * @date 2021/5/14
 */
public class BtConstant {

    /**
     * 协议帧头, {@link BtDataSplitCodecHandler}
     */
    public static final int FRAME_HEAD = NettyConstant.FRAME_HEAD;
    /**
     * 帧头的"数据大小",单位-字节;
     * 1个int占4个byte/字节
     */
    public static final int FRAME_HEAD_FIELD_SIZE = NettyConstant.FRAME_HEAD_FIELD_SIZE;
    /**
     * 数据长度field的偏移量,单位-字节, {@link BtDataSplitCodecHandler}
     */
    public static final int FRAME_LENGTH_FIELD_OFFSET = NettyConstant.FRAME_LENGTH_FIELD_OFFSET;
    /**
     * 数据长度field的"数据大小",单位-字节, {@link BtDataSplitCodecHandler}
     */
    public static final int FRAME_LENGTH_FIELD_SIZE = NettyConstant.FRAME_LENGTH_FIELD_SIZE;

    public static final String SERVER_NAME = "MiniController";
    public static final UUID BT_UUID = UUID.fromString("53A382C5-8AC8-E559-0C06-6722924734D3");

    /**
     * 预定义的数据类型
     */
    public interface BtDataType {
        /**
         * 异常信息
         */
        int EXCEPTION = DataType.EXCEPTION;
        /**
         * 登陆认证请求,由客户端发送
         */
        int LOGIN_REQUEST = DataType.LOGIN_REQUEST;
        /**
         * 登陆认证回复,由服务端发送
         */
        int LOGIN_RESPONSE = DataType.LOGIN_RESPONSE;
        /**
         * 心跳包
         */
        int HEARTBEAT = DataType.HEARTBEAT;
    }
}
